<?php

// Connecting to Redis server on localhost
$redis = new Redis();
$redis->connect('127.0.0.1', 6699); //连接Redis
$redis->auth('Zxbp180119'); //密码验证
$redis->select(2);//选择数据库2
$redis->set( "testKey" , "Hello Redis"); //设置测试key
echo $redis->get("testKey");//输出value

$dsn = 'mysql:host=localhost;dbname=answer';
$user = 'answer';
$password = 'answer';
$status = 1;

try {
    $sql = 'select * from an_setting';
    $dbh = new PDO($dsn, $user, $password);
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $dbh->prepare($sql);
    $stmt->bindParam(':status', $status);
    $stmt->execute();
    //返回插入、更新、删除的受影响行数
    // echo $stmt->rowCount();
    //返回最后插入的id
    // echo 'ID of last insert:'.$dbh->lastInsertId();
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        echo $row['id'] . "\t" . $row['status'] . '</br>';
    }
} catch (PDOException $e) {
    echo 'SQL Query:' . $sql . '</br>';
    echo 'Connection failed:' . $e->getMessage();
}